﻿using System;
using System.Windows;
using System.Windows.Controls;

namespace WellDone
{
    public partial class EditConfiguration : ChildWindow
    {
        public ServiceReferenceOpenRPOS.Configuration cf;

        public EditConfiguration()
        {
            InitializeComponent();
        }

        private async void OKButton_Click(object sender, RoutedEventArgs e)
        {
            if (tbConfigKey.Text.Trim().Length > 0)
            {
                try
                {
                    cf.col_KeyName = tbConfigKey.Text; cf.bFilterKeyName = true;
                    cf.col_Value = tbConfigValue.Text; cf.bFilterValue = true;
                }
                catch (Exception) { }
                await Globals.db.UpdateConfigurationObject(cf);
                Globals.configuration.init();
                this.DialogResult = true;
            }
            else
            {
                MessageBox.Show("Please enter a valid Key Name", "Warning", MessageBoxButton.OK);
            }
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }
    }
}

